export default {
	state: {
        TOP_obj: {
            list: [{ name: 'index', title: '首页' },
            {name: "user", title: "用户"}],
            active: '',
        }
	},
	mutations: {
        SAVETOP_COLUMN(state, TOP_COLUMN) {
            state.TOP_obj.list = [...state.TOP_obj.list, TOP_COLUMN]
        },
        REMOVETOP_COLUMN(state, index) {
            state.TOP_obj.list.splice(index, 1)
            state.TOP_obj.active = state.TOP_obj.list[state.TOP_obj.list.length - 1].name
        },
        SAVETOP_ACTIVE(state, active) {
            state.TOP_obj.active = active
        },
        closeOtherTabs(state, index) {
            let list=[]
            if (index == 0) {
                list = JSON.parse(JSON.stringify([state.TOP_obj.list[0]]))
            } else {
                list = JSON.parse(JSON.stringify([state.TOP_obj.list[0], state.TOP_obj.list[index]]))
            }
            state.TOP_obj.list = [...list]
        },
        closeleftTabs(state, index) {
            let list = state.TOP_obj.list.slice(0, index )
            state.TOP_obj.list = [...list]
        },
        closerightTabs(state, index) {
            let list = state.TOP_obj.list.slice(0, index + 1)
            state.TOP_obj.list = [...list]
        },


            // let list=[]
            // if (index == 0) {
            //     list = JSON.parse(JSON.stringify([state.TOP_obj.list[0]]))
            // } else {
            //     list = JSON.parse(JSON.stringify(state.TOP_obj.list)).slice(0,index)
            // }
            // state.TOP_obj.list = [...list]
	}
}
